package com.surveillance.validators;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.surveillance.entities.User;
import com.surveillance.util.NiveauSpecialiteBundle;

@Component
public class AffectatonEtudiantsValidator1 implements Validator {
	@Override
	public boolean supports(Class clazz) {
		return User.class.isAssignableFrom(clazz);
	}
	@Override
	public void validate(Object target, Errors errors) {
		NiveauSpecialiteBundle saft= (NiveauSpecialiteBundle) target;
		if(saft.getExamen().equals("")){
			ValidationUtils.rejectIfEmptyOrWhitespace(errors,"examen","required.examen");
		}
		if(saft.getNiveau().equals("")){
			ValidationUtils.rejectIfEmptyOrWhitespace(errors,"niveau","required.level");
		}
		if(saft.getSpecialite().equals("")){
			ValidationUtils.rejectIfEmptyOrWhitespace(errors,"specialite","required.major");
		}
	}

}
